package com.example.demo.chapter3;


import java.util.Arrays;
import java.util.EventListener;

public class ThisEscape {


    public People[] copy(People[] a){
        return Arrays.copyOf(a,a.length);
    }


    public static void main(String[] args) {
        People[] a = {new People("张三",15)};
        ThisEscape escape = new ThisEscape();
        People[] copy = escape.copy(a);
        System.out.println(copy[0]);
        System.out.println(a[0]);
        a[0].setUsername("lisi");
        System.out.println(copy[0].getUsername());
    }

    static class People{
        String username;
        int age;

        public People(String username, int age) {
            this.username = username;
            this.age = age;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }
    }
}
